package com.mfs.common.utills;

import com.mfs.common.exception.AssertException;

/**
 * 断言
 * @author mfs
 * @date 2023/7/1 15:20
 **/
public class Assert {

    public static void notNull(Object o) {
        notNull(o, "can't be null");
    }

    public static void notNull(Object o, String message) {
        if (o == null) {
            throw new AssertException(message);
        }
    }
    public static void notEmpty(CharSequence charSequence) {
        notEmpty(charSequence, "can't empty");
    }


    public static void notEmpty(CharSequence charSequence, String message) {
        if (charSequence == null || charSequence.length() < 1) {
            throw new AssertException(message);
        }
    }

    public static void notBlank(CharSequence charSequence) {
        notBlank(charSequence, "can't blank");
    }


    public static void notBlank(CharSequence charSequence, String message) {
        if (charSequence == null || StringUtil.isBlank(charSequence.toString())) {
            throw new AssertException(message);
        }
    }
}
